package red.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import red.dao.ArticleDao;
import red.dao.impl.ArticleDaoImpl;
import red.mapper.Articlemapper;
import red.model.ArticleModel;
import red.service.ArticleService;
import red.util.Model;

import java.util.List;
import java.util.UUID;

@Service
public class ArticleServiceImpl implements ArticleService {
    @Autowired
    private Articlemapper articlemapper;
    @Override
    public ArticleModel deleteartic(Model model) {
        String headline = (String) model.get("headline");
        ArticleModel articleModel = new ArticleModel();
        articleModel.setColumn_id(UUID.randomUUID().toString());
        articleModel.setHeadline(headline);
        articlemapper.deleteArticle(articleModel);
        return articleModel;
    }

    @Override
    public List<ArticleModel> selectall(Model model) {
        ArticleModel articleModel = new ArticleModel();
        return articlemapper.selectall(articleModel);
    }

    @Override
    public List<ArticleModel> selectarticle(Model model) {
        String headline = (String) model.get("headline");
        ArticleModel articleModel = new ArticleModel();
      //  articleModel.setColumn_id(UUID.randomUUID().toString());
        articleModel.setHeadline(headline);
        articlemapper.selectArticle(articleModel);
        return articlemapper.selectArticle(articleModel);
    }


}
